package com.example.tests;

public class ContactFromFormData implements Comparable<ContactFromFormData> {
		private String firstName;
		private String lastName;
		private String address;
		private String homePhone;
		private String mobilePhone;
		private String workPhone;
		private String email1;
		private String email2;
		private String bDay;
		private String bMonth;
		private String bYear;
		private String address2;
		private String phone2;

		public ContactFromFormData(String firsName, String lastName, String address,
				String homePhone, String mobilePhone, String workPhone,
				String email1, String email2, String bDay, String bMonth,
				String bYear, String contactGroup, String address2, String phone2) {
			this.firstName = firsName;
			this.lastName = lastName;
			this.address = address;
			this.homePhone = homePhone;
			this.mobilePhone = mobilePhone;
			this.workPhone = workPhone;
			this.email1 = email1;
			this.email2 = email2;
			this.bDay = bDay;
			this.bMonth = bMonth;
			this.bYear = bYear;
			this.address2 = address2;
			this.phone2 = phone2;
		}
		
		public ContactFromFormData() {
		}
		
	@Override
		public String toString() {
			return "ContactFromFormData [firstName=" + firstName
					+ ", lastName=" + lastName + ", address=" + address
					+ ", homePhone=" + homePhone + ", mobilePhone="
					+ mobilePhone + ", workPhone=" + workPhone + ", email1="
					+ email1 + ", email2=" + email2 + ", bDay=" + bDay
					+ ", bMonth=" + bMonth + ", bYear=" + bYear + ", address2="
					+ address2 + ", phone2=" + phone2 + "]";
		}
	
	public ContactFromFormData withFirstName(String firstName) {
		this.firstName = firstName;
		return this;
	}

	public ContactFromFormData withLastName(String lastName) {
		this.lastName = lastName;
		return this;
	}

	public ContactFromFormData withAddress(String address) {
		this.address = address;
		return this;
	}

	public ContactFromFormData withAddress2(String address2) {
		this.address2 = address2;
		return this;
	}

	public ContactFromFormData withBYear(String bYear) {
		this.bYear = bYear;
		return this;
	}

	public ContactFromFormData withEmail1(String email1) {
		this.email1 = email1;
		return this;
	}

	public ContactFromFormData withEmail2(String email2) {
		this.email2 = email2;
		return this;
	}

	public ContactFromFormData withHomePhone(String homePhone) {
		this.homePhone = homePhone;
		return this;
	}

	public ContactFromFormData withMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
		return this;
	}

	public ContactFromFormData withPhone2(String phone2) {
		this.phone2 = phone2;
		return this;
	}

	public ContactFromFormData withWorkPhone(String workPhone) {
		this.workPhone = workPhone;
		return this;
	}

	public ContactFromFormData withBDay(String bDay) {
		this.bDay = bDay;
		return this;
	}

	public ContactFromFormData withBMonth(String bMonth) {
		this.bMonth = bMonth;
		return this;
	}

	@Override
	public int compareTo(ContactFromFormData other) {
		int res = this.lastName.toLowerCase().compareTo(other.lastName.toLowerCase());
		if (res == 0) {
			res = this.firstName.toLowerCase().compareTo(other.firstName.toLowerCase());
		}
		if (res == 0) {
			res = this.address.toLowerCase().compareTo(other.address.toLowerCase());
		}
		if (res == 0) {
			res = this.homePhone.toLowerCase().compareTo(other.homePhone.toLowerCase());
		}
		if (res == 0) {
			res = this.mobilePhone.toLowerCase().compareTo(other.homePhone.toLowerCase());
		}
		if (res == 0) {
			res = this.workPhone.toLowerCase().compareTo(other.workPhone.toLowerCase());
		}
		if (res == 0) {
			res = this.email1.toLowerCase().compareTo(other.email1.toLowerCase());
		}
		if (res == 0) {
			res = this.email2.toLowerCase().compareTo(other.email2.toLowerCase());
		}
		if (res == 0) {
			res = this.bDay.toLowerCase().compareTo(other.bDay.toLowerCase());
		}
		if (res == 0) {
			res = this.bMonth.toLowerCase().compareTo(other.bMonth.toLowerCase());
		}
		if (res == 0) {
			res = this.bYear.toLowerCase().compareTo(other.bYear.toLowerCase());
		}
		if (res == 0) {
			res = this.address2.toLowerCase().compareTo(other.address2.toLowerCase());
		}
		if (res == 0) {
			res = this.phone2.toLowerCase().compareTo(other.phone2.toLowerCase());
		}
		return res;
			
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result
				+ ((address2 == null) ? 0 : address2.hashCode());
		result = prime * result + ((bDay == null) ? 0 : bDay.hashCode());
		result = prime * result + ((bMonth == null) ? 0 : bMonth.hashCode());
		result = prime * result + ((bYear == null) ? 0 : bYear.hashCode());
		result = prime * result + ((email1 == null) ? 0 : email1.hashCode());
		result = prime * result + ((email2 == null) ? 0 : email2.hashCode());
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result
				+ ((homePhone == null) ? 0 : homePhone.hashCode());
		result = prime * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result
				+ ((mobilePhone == null) ? 0 : mobilePhone.hashCode());
		result = prime * result + ((phone2 == null) ? 0 : phone2.hashCode());
		result = prime * result
				+ ((workPhone == null) ? 0 : workPhone.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactFromFormData other = (ContactFromFormData) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (address2 == null) {
			if (other.address2 != null)
				return false;
		} else if (!address2.equals(other.address2))
			return false;
		if (bDay == null) {
			if (other.bDay != null)
				return false;
		} else if (!bDay.equals(other.bDay))
			return false;
		if (bMonth == null) {
			if (other.bMonth != null)
				return false;
		} else if (!bMonth.equals(other.bMonth))
			return false;
		if (bYear == null) {
			if (other.bYear != null)
				return false;
		} else if (!bYear.equals(other.bYear))
			return false;
		if (email1 == null) {
			if (other.email1 != null)
				return false;
		} else if (!email1.equals(other.email1))
			return false;
		if (email2 == null) {
			if (other.email2 != null)
				return false;
		} else if (!email2.equals(other.email2))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (homePhone == null) {
			if (other.homePhone != null)
				return false;
		} else if (!homePhone.equals(other.homePhone))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (mobilePhone == null) {
			if (other.mobilePhone != null)
				return false;
		} else if (!mobilePhone.equals(other.mobilePhone))
			return false;
		if (phone2 == null) {
			if (other.phone2 != null)
				return false;
		} else if (!phone2.equals(other.phone2))
			return false;
		if (workPhone == null) {
			if (other.workPhone != null)
				return false;
		} else if (!workPhone.equals(other.workPhone))
			return false;
		return true;
	}
}
